/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.odhixon.volarme.gui;

import com.sun.lwuit.events.DataChangedListener;
import com.sun.lwuit.events.SelectionListener;
import com.sun.lwuit.list.ListModel;

/**
 * ObjectsModel.
 * @author Ariel Aguirre <odhixon@gmail.com>
 */
public abstract class ObjectsModel implements ListModel {

    protected Object[] objects;
    private int selection;

    public Object getItemAt(int index) {
        return objects[index];
    }

    public int getSize() {
        int size;
        if (objects == null) {
            size = 0;
        } else {
            size = objects.length;
        }
        return size;
    }

    public int getSelectedIndex() {
        return selection;
    }

    public void setSelectedIndex(int index) {
        selection = index;
    }

    public void addDataChangedListener(DataChangedListener listener) {
    }

    public void removeDataChangedListener(DataChangedListener listener) {
    }

    public void addSelectionListener(SelectionListener listener) {
    }

    public void removeSelectionListener(SelectionListener listener) {
    }

    public void addItem(Object object) {
    }

    public void removeItem(int index) {
    }

    public int find(Object object) {
        int index = objects.length;
        while(index<0 && !objects[index].toString().equals(object.toString())) {
            index--;
        }
        return index;
    }

    public abstract void load();
}
